package com.example.mylibrary.callback;


import com.example.mylibrary.exception.ApiException;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * Created by 陈致远 on 2021/1/11.
 */
public abstract class BaseObserver implements Observer {
    @Override
    public void onSubscribe(Disposable d) {

    }


    @Override
    public void onError(Throwable e) {
        if (e instanceof ApiException) {
            ApiException apiException = (ApiException) e;
            error(apiException.getMsg(), apiException.getCode());
        }
    }

    @Override
    public void onComplete() {

    }

    protected abstract void error(String error, int code);
}
